import sqlite3
from config import DB_FILE, TABLE_NAME
    
def get_tables() -> list[str]:
    conn = sqlite3.connect(DB_FILE)
    cursor = conn.cursor()
    cursor.execute(f"SELECT table_name FROM {TABLE_NAME}")
    tables = [row[0] for row in cursor.fetchall()]
    conn.close()
    return tables

def get_table_schema(table_name: str) -> list[dict]:
    conn = sqlite3.connect(DB_FILE)
    cursor = conn.cursor()
    cursor.execute(f"SELECT table_ddl FROM {TABLE_NAME} WHERE table_name = ?", (table_name,))
    row = cursor.fetchone()
    conn.close()
    if row:
        return row[0]
    else:
        raise ValueError(f"Table '{table_name}' not found in the database.")
    